public class Demo13 {
    public static void main(String[] args) {
        Person p1 = new Person();
        p1.setName("");
        p1.setAge(30);
        System.out.println("我叫" + p1.getName() + ",我的年龄是" + p1.getAge());

        Person2 p2 = new Person2();
        p2.setBirth(2000);
        System.out.println("我今年" + p2.getAge() + "岁");

        System.out.println("------------------------------");
        Person3 ming = new Person3();
        ming.setName("小明");
        ming.setAge(12);
        System.out.println(ming.getAge());
    }
}

class Person {
    private String name;
    private int age;

    public void setName(String name) {
        if (name == null || name.isBlank()) {
            System.out.println("名字不能为空");
        } else {
            this.name = name;
        }
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return this.name;
    }

    public int getAge() {
        return this.age;
    }
}

class Person2 {
    private String name;
    private int birth;

    public int getAge() {
        return this.birth;
    }

    public void setBirth(int year) {
        this.setYear(year);
    }

    private void setYear(int year) {
        this.birth = 2025 - year;
    }
}

class Person3 {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

}